import java.util.Objects;

class Person{
    public int id;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return id == person.id;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}


public class HashBuck2<K,V> {
    static class Node<K,V>{
        public K key;
        public V val;
        public Node<K,V>next;
        public Node(K key,V val){
            this.key=key;
            this.val=val;
        }
    }
    public Node<K,V>[]array;
    public int usedSize;
    public HashBuck2(){
        array=(Node<K,V>[])new Node [10];
    }

    public void put(K key,V val){
        //自定义类型，
        //默认由C、C++代码写的
        //将对象转换为一个整数
        //为这个对象返回一个整数
        //重写所谓的hashcode
        int hash=key.hashCode();
        int index=hash%array.length;
        Node<K,V> cur=array[index];
        while(cur!=null){
            if(cur.key.equals(key)){//插入的是同一个key，那么就更新一下那个值，哈哈哈
                cur.val=val;
                return ;
            }
            cur=cur.next;
        }
        Node<K,V> node=new Node<>(key,val);
        node.next=array[index];
        array[index]=node;
        usedSize++;
    }
    //
    public V get(K key){
        int hash=key.hashCode();
        int index=hash%array.length;
        Node<K,V> cur=array[index];
        while(cur!=null){
            if(cur.key.equals(key)){
                return cur.val;
            }
        }
        return null;
    }
}
